<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">

    <title> - 登录</title>
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="css/animate.css" rel="stylesheet">
    <link href="css/style.css" rel="stylesheet">
    <link href="css/login.css" rel="stylesheet">
    <!--[if lt IE 9]>
    <meta http-equiv="refresh" content="0;ie.html" />
    <![endif]-->
    <script>
        if (window.top !== window.self) {
            window.top.location = window.location;
        }
    </script>
<%@ include file="/header.jsp"%>
</head>

<body class="signin">
    <div class="signinpanel">
        <div class="row">
            <div class="col-sm-12">
                <form method="post" action="" id="formId">
                    <h4 class="no-margins">员工管理系统</h4>
                    <p class="m-t-md">登录：</p>
                    <input type="text" class="form-control uname" placeholder="用户名" name="name" />
                    <input type="password" class="form-control pword m-b" placeholder="密码" name="password" />
                    <input type="text" class="form-control" placeholder="验证码" style="display: inline; width: 170px; margin-top: 0px" name="checkCode"/><img id="codeImg" alt="" src="${path}/checkCode" onclick="refreshCode()">
                    <a href="">忘记密码？</a>
                    <input class="btn btn-success btn-block" onclick="submitForm()" value="登录"/>
                </form>
            </div>
        </div>
        <div class="signup-footer">
            <div class="pull-left">
                &copy; hAdmin
            </div>
        </div>
    </div>
    
    <script type="text/javascript">
    	function refreshCode(){
    		$('#codeImg').attr('src', '${path}/checkCode?' + Math.random());
    	}
    	
    	function submitForm(){
    		  		
    		$.post(
    			'${path}/userLogIn?method=login',
    			$('#formId').serialize(), // 可以把form表的里面的数据自动封装成json格式
    			function(jsonObj){
    				if (jsonObj.code == 0) {
						mylayer.successUrl(jsonObj.msg, '${path}/index.jsp');
					} else {
						mylayer.errorMsg(jsonObj.msg);
					}
    			},
    			'json'
    		);
    	}
    </script>
</body>

</html>
